export LD_ARGS = \
-o output/bin/sdk.elf \
-Map=output/bin/map.txt \
-T../link.ld \
--plugin-opt=-enable-ipra=true \
--plugin-opt=-pi32v2-merge-max-offset=4096 \
--plugin-opt=-pi32v2-enable-simd=true \
--plugin-opt=-pi32v2-large-program=true \
--plugin-opt=mcpu=r3 \
--plugin-opt=-global-merge-on-const \
--plugin-opt=-inline-threshold=5 \
--plugin-opt=-inline-max-allocated-size=32 \
--plugin-opt=-inline-normal-into-special-section=true \
--plugin-opt=save-temps \
--plugin-opt=-pi32v2-enable-rep-memop \
--plugin-opt=-warn-stack-size=2560 \
--sort-common \
--dont-complain-call-overflow \


export LD = /opt/jieli-linux-toolchains-latest/pi32v2/bin/lto-wrapper

export OHOS_LIBS_DIR=ohos/libs

LIBS = --start-group



LIBS += --whole-archive

LIBS += $(wildcard $(OHOS_LIBS_DIR)/*.a)

#LIBS+= $(OHOS_LIBS_DIR)/libarch.a\
$(OHOS_LIBS_DIR)/libauthmanager.a\
$(OHOS_LIBS_DIR)/libbacktrace.a\
$(OHOS_LIBS_DIR)/libboard.a\
$(OHOS_LIBS_DIR)/libbootstrap.a\
$(OHOS_LIBS_DIR)/libbroadcast.a\
$(OHOS_LIBS_DIR)/libcjson_static.a\
$(OHOS_LIBS_DIR)/libcmsis.a\
$(OHOS_LIBS_DIR)/libcpu.a\
$(OHOS_LIBS_DIR)/libcpup.a\
$(OHOS_LIBS_DIR)/libdiscovery.a\
$(OHOS_LIBS_DIR)/libdump_static.a\
$(OHOS_LIBS_DIR)/libexchook.a\
$(OHOS_LIBS_DIR)/libhal_file_static.a\
$(OHOS_LIBS_DIR)/libhal_iothardware.a\
$(OHOS_LIBS_DIR)/libhal_sysparam.a\
$(OHOS_LIBS_DIR)/libhal_token_static.a\
$(OHOS_LIBS_DIR)/libhievent_lite.a\
$(OHOS_LIBS_DIR)/libhilog_lite.a\
$(OHOS_LIBS_DIR)/libhilog_lite_command.a\
$(OHOS_LIBS_DIR)/libhiview_lite.a\
$(OHOS_LIBS_DIR)/libhuks.a\
$(OHOS_LIBS_DIR)/libkal.a\
$(OHOS_LIBS_DIR)/libkernel.a\
$(OHOS_LIBS_DIR)/libled_example.a\
$(OHOS_LIBS_DIR)/libmbedtls.a\
$(OHOS_LIBS_DIR)/libnative_file.a\
$(OHOS_LIBS_DIR)/libopenssl_static.a\
$(OHOS_LIBS_DIR)/libposix.a\
$(OHOS_LIBS_DIR)/libsamgr.a\
$(OHOS_LIBS_DIR)/libsamgr_adapter.a\
$(OHOS_LIBS_DIR)/libsamgr_source.a\
$(OHOS_LIBS_DIR)/libsec.a\
$(OHOS_LIBS_DIR)/libstubs.a\
$(OHOS_LIBS_DIR)/libsysparam.a\
$(OHOS_LIBS_DIR)/libtoken_static.a\
$(OHOS_LIBS_DIR)/libtrans_service.a\
$(OHOS_LIBS_DIR)/libutils.a\
$(OHOS_LIBS_DIR)/libutils_kv_store.a\
$(OHOS_LIBS_DIR)/libwifikit.a\
$(OHOS_LIBS_DIR)/libwifiservice.a\














LIBS += 3rd_sdk/cpu/ac791x/liba/wl_rf_common.a \
		3rd_sdk/cpu/ac791x/liba/wl_wifi_sfc.a \
		3rd_sdk/cpu/ac791x/liba/wpasupplicant.a \
		3rd_sdk/cpu/ac791x/liba/lwip_2_1_2_sfc.a \
		3rd_sdk/cpu/ac791x/liba/hsm.a \
		3rd_sdk/cpu/ac791x/liba/fs.a \



LIBS += --no-whole-archive



LIBS += /opt/jieli-linux-toolchains-latest/pi32v2/lib/r3/libc.a \
		/opt/jieli-linux-toolchains-latest/pi32v2/lib/r3/libm.a \
		3rd_sdk/cpu/ac791x/liba/libcompiler-rt.a \





LIBS += --end-group

.PHONY: out

out:
	@echo "LINK ..."
	$(LD) $(LD_ARGS) $(LIBS)
